<template>
	<view class="content">
		<!-- 顶部高度隔离 -->
		<view class="top-height" ref="topHeight"></view>
		<!-- 搜索框 -->
		<view class="search">
			<u-search v-model="seachValue" bg-color="#2f2f2f"
			placeholder="" @search="search"  :show-action="false" color="#ffffff"
			margin="0rpx 40rpx"></u-search>
		</view>
		<!-- 文字 Create按钮 -->
		<view class="create">
			<u-row gutter="0">
				<u-col span="6" >
					<!-- One文本 -->
					<view class="wbtext">
						<text>One ideabook</text>
					</view> 
				</u-col>
				<u-col span="2" >
				</u-col>
				<u-col span="4">
						
					<!-- #ifndef MP-WEIXIN -->
						<!-- Create按钮 -->
						<u-button @click="createButton" class="createButton"
						:plain="true"  size="40">
						<!-- 内部的+号 -->
						<u-icon name="plus" size="25"></u-icon>
						Create
						</u-button>
					<!-- #endif -->
					
					<!-- #ifdef MP-WEIXIN -->
						<!-- Create按钮 -->
						<button @click="createButton"  class="createButton"
						:plain="true"  size="40">
						<!-- 内部的+号 -->
						<u-icon name="plus" size="25"></u-icon>
						Create
						</button>
					<!-- #endif -->
					
				</u-col>
			</u-row>
		</view>
		
		<!-- 信息列表 -->
		
				<scroll-view v-if="list" scroll-y style="height: calc(100vh);width: 100%; color: #FFFFFF;" @scrolltolower="onreachBottom">
					<!-- 内部展示数据列表 -->
					<view class="imglist">
						<view class="imgbox" v-for="(item,index) in list" :key="index" @click="clickImg(index)">
							<image class="img" :src="item.img"></image>
							<view class="titletext">
								<text>{{item.title}}</text>
							</view>
							<view class="mintext">
								<text>{{item.idea}}</text>
							</view>
						</view>
					</view>
					
				</scroll-view>
				
				<view v-else class="msgbox">
					<view style="height: 400rpx;">
					</view>
					<view>
						<u-icon name="email" size="200"></u-icon>
						<view>No Messages Yet</view>
					</view>
					<view style="height: 400rpx;">
					</view>
				</view>
	</view>
</template>

<script>
	import uAvatar from "@/uviewui/components/u-avatar/u-avatar.vue"
	import uButton from "@/uviewui/components/u-button/u-button.vue"
	
	export default {
		async onLoad(){
			
			//消息数据list
			await this.$u.api.getItemList('/0','/10').then(res=>{
				console.log('ItemList数据获取成功')
				if(res.success){
					this.$data.list = this.$u.deepClone(res.data)
				}
			}).catch(err=>{
				console.log('ItemList数据获取失败')
				console.log(err)
			})
			
		},
		components:{
			uAvatar,
			uButton,
		},
		data() {
			return {
				seachValue:"",
				list:[]
			}
		},
		methods: {
			search(){
				console.log('搜索')
			},
			createButton(){
				console.log('create按钮事件')
			},
			clickImg(index){
				console.log('img点击事件'+index)
			},
			onreachBottom(e){
				console.log(e)
			}
		}
	}
</script>

<style lang="scss">
	//整体背景色
	.content{
		background-color: #222222;
		
		// 创建栏样式
		.create{
			width: 100%;
			margin: 20rpx 30rpx;
			// One idea文本样式
			.wbtext{
				font-size: 30rpx;
				color: #FFFFFF;
				font-weight: 700;
				/* #ifdef MP-WEIXIN */
					line-height: 80rpx;
				/* #endif */
			}
			// create按钮样式
			.createButton{
				color: #4EAC95;
				text-align: center;
				font-size: 33rpx;
				background-color: #222222;
				font-weight: 400;
				border:#4EAC95 2rpx solid;
				/* #ifndef MP-WEIXIN */
					width: 150rpx;
					height: 70rpx;
				/* #endif */
				/* #ifdef MP-WEIXIN */
					margin-left: 110rpx;
					
					width: 185rpx;
					height: 80rpx;
				/* #endif */
			}
		}
		
		.imglist{
			color:#FFFFFF;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: center;
			width: 100%;
			.imgbox{
				width: 346rpx;
				display: flex;
				flex-direction: column;
				background-color: #333333;
				margin: 15rpx auto;
				border-radius: 10rpx;
				justify-content: center;
				.img{
					margin: 5rpx;
					border-radius: 10rpx;
					width: 340rpx;
					height: 300rpx;
				}
				.titletext{
					margin-left: 14rpx;
					margin-top: 14rpx;
					font-size: 26rpx;
				}
				.mintext{
					margin-left: 14rpx;
					margin-top: 30rpx;
					font-size: 26rpx;
					margin-bottom: 30rpx;
				}
			}
		}
	}
	//===================================
	//顶部高度隔离
	/* #ifdef APP-PLUS */
		.top-height{
			height: 60rpx;
		}
	/* #endif */
	/* #ifdef MP-WEIXIN */
		.top-height{
			height: 140rpx;
		}
	/* #endif */
	/* #ifdef H5 */
	.top-height{
		height: 80rpx;
	}
	/* #endif */
	//===================================
	.msgbox{
		width: 100%;
		background-color: #222222;
		display: flex;
		flex-direction: column;
		justify-content: center;
		text-align: center;
		height: 1092rpx;
		color: #888888;
	}
	
	
</style>
